home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir43 / med300.zip / MESCREEN.CLA < prev    next >
Text File  |  1994-02-22  |  11KB  |  210 lines

  1.  
  2. !▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  3. !█                                                                       █
  4. !█ MESCREEN.CLA                                                          █
  5. !█ Screen and cursor-related procedures                                  █
  6. !█                                                                       █
  7. !█ Revision Number: 1                                                    █
  8. !█ Revision Date  : 22-Feb-94                                            █
  9. !█                                                                       █
  10. !█ Revision History                                                      █
  11. !█   1 Created                                                           █
  12. !█                                                                       █
  13. !▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  14.  
  15.               MEMBER('MEMOEDIT')
  16.  
  17. !─────────────────────────────────────────────────────────────────────────
  18. !                            Local Module MAP
  19. !─────────────────────────────────────────────────────────────────────────
  20.               MAP
  21.                 ME_FormLine( USHORT, USHORT )
  22.               .
  23.  
  24. !─────────────────────────────────────────────────────────────────────────
  25. !                           Local Module Data
  26. !─────────────────────────────────────────────────────────────────────────
  27. sLine         STRING(512)                        ! Display line buffer
  28. aLine         BYTE,DIM(512),OVER(sLine)          ! Array alias for above
  29.  
  30.  
  31. !═════════════════════════════════════════════════════════════════════════
  32. !                Position cursor, scrolling screen if necessary
  33. !═════════════════════════════════════════════════════════════════════════
  34. ME_CurPos    PROCEDURE
  35.  
  36.              ! Locals:
  37. isDspCol     SHORT                               ! Display column
  38. isSkewDelta  SHORT                               ! Horizontal pan delta
  39.  
  40.   CODE
  41.   isSkewDelta = 0.25 * (MED:ubWndCols - 1)       ! Set horizontal pan delta
  42.  
  43.   IF MED:usLineNdx <= MED:usPageTop              ! If position above
  44.     MED:usPageTop = MED:usLineNdx - 1            !   Set to first row
  45.     ME_SetPage()                                 !   Screen needs refresh
  46.                                                  ! Else if position below
  47.   ELSIF MED:usLineNdx > (MED:usPageTop + MED:ubWndRows)
  48.     IF MED:usLineNdx < MED:ubWndRows             !
  49.       MED:usPageTop = 0                          !
  50.     ELSE                                         !
  51.       MED:usPageTop = MED:usLineNdx - MED:ubWndRows
  52.     .                                            !
  53.     ME_SetPage()                                 !   Screen needs refresh
  54.   .                                              ! Endif
  55.  
  56.   isDspCol = MED:usPosition - MED:usLineStart    !
  57.  
  58.   IF isDspCol < MED:isSkew                       ! If off screen left
  59.     MED:isSkew = isDspCol - isSkewDelta          !   Scroll left
  60.     IF MED:isSkew < 0 THEN MED:isSkew = 0.       !
  61.     ME_SetPage()                                 !   Screen needs refresh
  62.   ELSIF isDspCol > MED:isSkew + (MED:ubWndCols -1)! Else if off screen right
  63.     MED:isSkew = isDspCol - (MED:ubWndCols - 1) + isSkewDelta
  64.     ME_SetPage()                                 !   Screen needs refresh
  65.   .                                              ! Endif
  66.  
  67.   ME_ShowPage()                                  ! Display page
  68.  
  69.   MEG:ubCursCol = 1 + (MED:ubWndColOfs + (isDspCol - MED:isSkew))
  70.   MEG:ubCursRow = MED:ubWndRowOfs + (MED:usLineNdx - MED:usPageTop)
  71.   SETCURSOR(MEG:ubCursRow, MEG:ubCursCol)        ! Show cursor
  72.   ME_CurSize( MED:bbInsertMode )                 ! Set cursor size
  73.   RETURN                                         !
  74.  
  75.  
  76. !═════════════════════════════════════════════════════════════════════════
  77. !                           Set cursor size
  78. !═════════════════════════════════════════════════════════════════════════
  79. ME_CurSize   PROCEDURE( bbInsertMode )
  80.  
  81.              ! Locals:
  82. sCursorSize  STRING('<07><06><07><04>')          ! Cursor sizes
  83. aCursorSize  SHORT,DIM(2),OVER(sCursorSize)      !
  84.  
  85. gRegisters   GROUP                               ! CPU Registers
  86. usAX           USHORT                            !
  87. usBX           USHORT                            !
  88. usCX           USHORT                            !
  89. usDX           USHORT                            !
  90. usSI           USHORT                            !
  91. usDI           USHORT                            !
  92. usCFlag        USHORT                            !
  93. usFlags        USHORT                            !
  94.              .                                   !
  95.  
  96. gSegRegs     GROUP                               ! CPU Segment Registers
  97. usES           USHORT                            !
  98. usCS           USHORT                            !
  99. usSS           USHORT                            !
  100. usDS           USHORT                            !
  101.              .                                   !
  102.  
  103.   CODE
  104.   CLEAR(gRegisters)                              ! Clear group
  105.   usAX  = 0100H                                  ! Set Cursor Size request
  106.   usCX  = aCursorSize[1+bbInsertMode]            ! Select cursor size
  107.   Junk# = Int86x(10H, gRegisters, gRegisters, gSegRegs)
  108.   RETURN                                         !
  109.  
  110.  
  111. !═══════════════════════════════════════════════════════════════════════
  112. !   Set the current page to redisplay on the next call to ME_ShowPage()
  113. !═══════════════════════════════════════════════════════════════════════
  114. ME_SetPage    PROCEDURE
  115.  
  116.               ! Locals:
  117. usLines       USHORT                             ! Line count
  118. usIndex       USHORT                             ! Loop index
  119.  
  120.   CODE
  121.   usLines = ME_Min(MED:ubWndRows, (RECORDS(qLine) - MED:usPageTop))
  122.   LOOP usIndex = 1 TO usLines                    ! Loop for each line on page
  123.     GET(qLine, MED:usPageTop + usIndex)          !   Get line table entry
  124.     QLN:bbRedisplay = 1                          !   Set display flag
  125.     PUT(qLine)                                   !   Store back to table
  126.   .                                              ! End loop
  127.   RETURN
  128.  
  129.  
  130. !═══════════════════════════════════════════════════════════════════════
  131. !                          Format Display Line
  132. !═══════════════════════════════════════════════════════════════════════
  133. ME_FormLine   PROCEDURE( usStartOfs, usEndOfs )
  134.  
  135.               ! Locals:
  136. usFillWord    USHORT                             ! Fill character/attribute
  137. isBlkBeg      SHORT                              ! Block begin
  138. isBlkEnd      SHORT                              ! Block end
  139. usSourceNdx   USHORT                             ! Source index
  140. usDestNdx     USHORT                             ! Destination index
  141. ubAttrib      BYTE                               ! Attribute byte
  142. ubChar        BYTE                               ! Character code
  143.  
  144.   CODE
  145.   usFillWord = BSHIFT(MED:ubTextColor, 8) + 20H  ! Set line to fill character
  146.   CMemWSet(ADDRESS(aLine), usFillWord, SIZE(aLine) / 2)
  147.   usDestNdx = 1                                  ! Set dest. index
  148.   LOOP usSourceNdx = usStartOfs TO usEndOfs      ! Loop thru range
  149.     ubAttrib = MED:ubTextColor                   !   Set attribute
  150.     ubChar   = ME_GetChar(usSourceNdx)           !   Get character
  151.     IF MED:bbShowCodes                           !   Remap format codes
  152.       IF ubChar = eHRt                           !
  153.         ubChar   = eHRtSym                       !
  154.         ubAttrib = MED:ubSymColor                !
  155.     . .                                          !
  156.     aLine[usDestNdx] = ubChar                    !   Set character byte
  157.     usDestNdx += 1                               !   Update dest. index
  158.     IF MED:bbBlockShow                           !   Handle block marking
  159.       isBlkBeg = ME_Min(MED:isBlockBegin, MED:isBlockEnd)
  160.       isBlkEnd = ME_Max(MED:isBlockBegin, MED:isBlockEnd)
  161.       IF INRANGE(usSourceNdx, isBlkBeg, isBlkEnd)!
  162.         ubAttrib = MED:ubBlockColor              !
  163.     . .                                          !
  164.     aLine[usDestNdx] = ubAttrib                  !   Set attribute byte
  165.     usDestNdx += 1                               !   Update dest. index
  166.   .                                              ! End loop
  167.   RETURN
  168.  
  169.  
  170. !═══════════════════════════════════════════════════════════════════════
  171. !                        Display screen page
  172. !═══════════════════════════════════════════════════════════════════════
  173. ME_ShowPage   PROCEDURE
  174.  
  175.               ! Locals:
  176. usIndex       USHORT                             ! Loop index
  177. usDspRow      USHORT                             ! Display row
  178. usDspCol      USHORT                             ! Display column
  179. usDspCols     USHORT                             ! Display columns
  180. usStartOfs    USHORT                             ! Starting offset
  181. usEndOfs      USHORT                             ! Ending offset
  182. usStrLen      USHORT                             ! String length
  183. usCodeOfs     USHORT                             ! Format code offset
  184.  
  185.   CODE
  186.   LOOP usIndex = 1 TO MED:ubWndRows              ! Loop for each line on page
  187.     sLine     = ''                               !   Clear line buffer
  188.     usDspRow  = MED:ubWndRowOfs + usIndex        !   Set display values
  189.     usDspCol  = MED:ubWndColOfs + 1              !
  190.     usDspCols = MED:ubWndCols                    !
  191.  
  192.     CLEAR(qLine)                                 !   Get line table entry
  193.     GET(qLine, MED:usPageTop + usIndex)          !
  194.     IF ERRORCODE()                               !   Display blank if not found
  195.       QShow(sLine, usDspRow, usDspCol, usDspCols, MED:ubTextColor, 01H)
  196.     ELSIF QLN:bbRedisplay                        !   Else
  197.       QLN:bbRedisplay = 0                        !     Clear display flag
  198.       PUT(qLine)                                 !
  199.       usStartOfs = QLN:usLineStart + MED:isSkew  !     Calculate offsets
  200.       usEndOfs   = ME_LineEnd(MED:usPageTop + usIndex)
  201.       IF usStartOfs > usEndOfs                   !     If blank line
  202.         QShow(sLine, usDspRow, usDspCol, usDspCols, MED:ubTextColor, 01H)
  203.       ELSE                                       !     Else
  204.         usEndOfs = ME_Min(usEndOfs, usStartOfs + MED:ubWndCols)
  205.         ME_FormLine(usStartOfs, usEndOfs)        !       Format and display
  206.         QShow(sLine, usDspRow, usDspCol, usDspCols, 0, 80H)
  207.   . . .                                          ! End loop
  208.   RETURN
  209.  
  210.